import { RefObject } from 'react';

export interface DefaultProps {
  widget: any;
  widgetData: any;
  initCustomAttribute: (data: any, rect?: RectConfigCustom) => void;
  initCustomEventList: (data: any) => void;
  initStaticDataOrigin: (data: any) => void;
  widgetRef: RefObject<{ customEvent: (type: string, data?: any) => void }>;
  onWidgetUpdate: (widget: any) => void;
  convertImageUrl: (url: string) => string;
}

export interface RectConfigCustom {
  x?: number;
  y?: number;
  width: number;
  height: number;
}

export interface WidgetCustomGroup {
  groupName: string; //分组名称，空字符串则不分组
  id?: string; //用于动态增加配置时可查找删减
  defaultActive?: boolean; //是否默认展开分组
  // type: string;
  list: WidgetCustom[];
}
export interface WidgetCustom {
  label: string; //显示的名称
  field: string; //提交表单用到的字段
  type: CustomType; //组件类型
  value?: string | number | boolean;
  options?: Options; //单选下拉框组件时的选项数据
  placeholder?: string;
  explain?: string; //属性说明文本
  suffix?: string; //后缀
}
export type Options = { name: string; value: string }[];
export type CustomType =
  | 'text'
  | 'number'
  | 'select'
  | 'color'
  | 'image'
  | 'switch';
